package logic

import (
	"context"
	"zg2/zk1_user/userRpc/user"

	"zg2/zk1_user/api/internal/svc"
	"zg2/zk1_user/api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type ShowUserLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewShowUserLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ShowUserLogic {
	return &ShowUserLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *ShowUserLogic) ShowUser(req *types.ShowUserRequest) (resp *types.Response, err error) {
	// todo: add your logic here and delete this line

	showUser, err := l.svcCtx.UserRpc.ShowUser(l.ctx, &user.ShowUserRequest{Id: req.Id})
	if err != nil {
		return &types.Response{
			Message: err.Error(),
			Code:    500,
			Data:    nil,
		}, nil
	}
	return &types.Response{
		Message: "用户信息查询成功",
		Code:    500,
		Data:    showUser,
	}, nil
}
